package servlet;

import java.io.IOException;
import java.sql.Connection;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import service.CustomerManager;
import service.impl.CustomerManagerFactory;

/**
 * Servlet implementation class DeleteCustomer
 */
public class DeleteCustomer extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private CustomerManager manager;
       

    public DeleteCustomer() {
        super();
        manager=CustomerManagerFactory.getInstance();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String cname=request.getParameter("cname");
		Connection con=(Connection)request.getServletContext().getAttribute("connection");
		int m=manager.deleteCustomer(cname, con);
		if(m>0){
			//转发
			response.sendRedirect("list");
		}
		else{
			request.getRequestDispatcher("error.jsp").forward(request, response);
		}
		
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//接参

		
	}

}
